﻿/**
 * Licensed under the MIT License
 *
 * Copyright (c) 2010 Alexandre Croiseaux
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */
package project_name
{
	import marcel.core.Plugin;
	import marcel.debug.*;
	import marcel.events.StateEvent;

	import project_name.uis.content.*;
	import project_name.uis.header.HeaderUI;
	import project_name.uis.loaders.MainLoaderUI;
	import project_name.uis.nav.NavUI;

	import flash.events.Event;
	
	/**
	 * Project Entry Point Class
	 */
	public class Index extends Plugin
	{
		
		public function Index()
		{
			addEventListener(Event.COMPLETE, onReady);
		}
		
		private function onReady(e:Event = null):void
		{
			// class inclusion
			MainLoaderUI;
			HeaderUI;
			NavUI;
			PageUI; VideoUI; FormUI;
			
			// go
			debug("go to default state => " + config.getDefaultState());
			
			//assetManager.useFakeLoading();
			
			stateManager.addEventListener(StateEvent.END_STATE_OPEN, onStateOpened);
			stateManager.setDefaultState();
		}
		
		private function onStateOpened(e:StateEvent):void
		{
			debug("default state '" + e.currentStateId + "' opened !");
			
			stateManager.removeEventListener(StateEvent.END_STATE_OPEN, onStateOpened);
			
			//
			_initSample();
		}
		
		private function _initSample():void {
			//addChild(new WebcamSample());
			//addChild(new BitmapUtilsSample());
			//addChild(new DrawManagerSample());
			//addChild(new FullScreenManagerSample());
			//addChild(new SoundSample());
			//addChild(new ComponentsSample());
			//addChild(new FileLoaderSample());
			//addChild(new ScreenManagerSample());
			//addChild(new FacebookSample());
			//addChild(new GoogleMapSample());
			//addChild(new FrontControllerSample());
			//addChild(new TweenSample);
			//addChild(new TwitterSample());
			
		}
	}
	
}